Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rn layout hook #1662

Merged
merged 13 commits into from
Oct 18, 2024
Merged

feat: rn layout hook #1662

merged 13 commits into from
Oct 18, 2024

Conversation

yandadaFreedom
Copy link
Collaborator

No description provided.

@@ -0,0 +1,31 @@
import { TextStyle } from 'react-native'
import { Children, cloneElement } from 'react'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一起扔到utils里吧

textProps?: Record<string, any>
}

export function wrapChildren (props: Record<string, any> = {}, { hasVarDec, varContext }: WrapChildrenConfig, { textStyle, textProps } : TextConfig = {}) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WrapChildrenConfig和TextConfig合成一个config就行

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mpx-view也可以调用这个方法,外部再去拼bgImage就可以,

})
}
if (hasVarDec && varContext) {
children = <VarContext.Provider value={varContext}>{children}</VarContext.Provider>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加个key

@@ -130,6 +130,16 @@ const useInnerProps = (
const propsRef = useRef<Record<string, any>>({})
const eventConfig: { [key: string]: string[] } = {}
const config = rawConfig || { layoutRef: { current: {} }, disableTouch: false, disableTap: false }
const removeProps = [
'enable-background',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children也可以包括进来吧

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style应该也可以

const hasLayoutRef = useRef(false)
const layoutStyle: Record<string, any> = hasLayoutRef.current ? {} : DEFAULT_UNLAY_STYLE
const layoutProps: Record<string, any> = {}
if (hasSelfPercent || onLayout) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里还要判断一个props['enable-offset']

@hiyuki hiyuki merged commit 59a1a05 into master Oct 18, 2024
4 checks passed
@hiyuki hiyuki deleted the feat-layout-hook branch October 18, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants